function S = AIA_step2_S(Phi)
%     [M, N] = size(Phi);S11 = M*N;
    S11 = ~isnan(Phi);S11 = sum(S11(:),"omitnan");
    S12 = cos(Phi);S12 = sum(S12(:),"omitnan");
    S13 = sin(Phi);S13 = sum(S13(:),"omitnan");
    S22 = cos(Phi).*cos(Phi);S22 = sum(S22(:),"omitnan");
    S23 = cos(Phi).*sin(Phi);S23 = sum(S23(:),"omitnan");
    S33 = sin(Phi).*sin(Phi);S33 = sum(S33(:),"omitnan");
    S = [S11, S12, S13;
         S12, S22, S23;
         S13, S23, S33];
end